//---------------------------------------------------------------------
// <copyright file="UnitTestGeneratorTests.cs" company="Microsoft">
//     Copyright (c) Microsoft Corporation.  All rights reserved.
//     THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY
//     OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT
//     LIMITED TO THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR
//     FITNESS FOR A PARTICULAR PURPOSE.
// </copyright>
// <summary>The UnitTestGeneratorTests type.</summary>
//---------------------------------------------------------------------

namespace Microsoft.WcfUnit.Library.Test
{
    using System;
    using System.CodeDom;
    using System.IO;
    using System.ServiceModel;
    using Contracts;
    using Microsoft.VisualStudio.TestTools.UnitTesting;
    using Microsoft.WcfUnit.Library.Test.TestContracts;

    // TODO: More tests need to be moved from the TraceFileProcessorTests to UnitTestGeneratorTests
    [TestClass]
    public class UnitTestGeneratorTests
    {
        private const string ScenarioName = "TestScenario";
        private const string MainTestFile = ScenarioName + ".cs";
        private const string StubTestFile = ScenarioName + ".stubs";
        private string comment = "11/15/2007 00:00:00";

        [TestInitialize]
        public void Initialize()
        {
        }

        public void ValueTypeTestMethod(int a)
        {
        }

        [TestMethod]
        public void UTGValueTypeIsGeneratedAsARefParameterOnTheStubWhenHasAnInitialValue()
        {
            UnitTestGenerator utg = CreateUnitTestGenerator();
            utg.GenerateServiceCall(
                null,
                this.GetType().GetMethod("ValueTypeTestMethod"),
                new CallParameterInfo[] { new CallParameterInfo("a", typeof(int), FieldDirection.In, 1) },
                this.comment);
            CheckCode(utg,
@"//------------------------------------------------------------------------------
// <auto-generated>
//     This code was generated by a tool.
//     Runtime Version:2.0.50727.1433
//
//     Changes to this file may cause incorrect behavior and will be lost if
//     the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------

namespace TestNamespace
{
    using Microsoft.VisualStudio.TestTools.UnitTesting;
    using System.Collections.Generic;
    
    
    [TestClass()]
    [System.Diagnostics.CodeAnalysis.SuppressMessage(""Microsoft.Design"", ""CA1001:TypesThatOwnDisposableFieldsShouldBeDisposable"", Justification=""proxy should not be disposed"")]
    public partial class TestClass
    {
        
        private TestContext _testContext;
        
        private Microsoft.WcfUnit.Library.Test.UnitTestGeneratorTests unitTestGeneratorTestsClient;
        
        public TestContext TestContext
        {
            get
            {
                return this._testContext;
            }
            set
            {
                this._testContext = value;
            }
        }
        
        [TestMethod()]
        public void TestScenario()
        {
            // 11/15/2007 00:00:00
            this.ValueTypeTestMethod();
        }
        
        private void ValueTypeTestMethod()
        {
            int a = 1;
            this.CustomiseValueTypeTestMethod(ref a);
            _testContext.BeginTimer(""TestScenario_ValueTypeTestMethod"");
            try
            {
                unitTestGeneratorTestsClient.ValueTypeTestMethod(a);
            }
            finally
            {
                _testContext.EndTimer(""TestScenario_ValueTypeTestMethod"");
            }
        }
    }
}
",
@"//------------------------------------------------------------------------------
// <auto-generated>
//     This code was generated by a tool.
//     Runtime Version:2.0.50727.1433
//
//     Changes to this file may cause incorrect behavior and will be lost if
//     the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------

namespace TestNamespace
{
    using Microsoft.VisualStudio.TestTools.UnitTesting;
    using System.Collections.Generic;
    
    
    public partial class TestClass
    {
        
        private static Dictionary<int, Microsoft.WcfUnit.Library.Test.UnitTestGeneratorTests> unitTestGeneratorTestsProxyTable = new Dictionary<int, Microsoft.WcfUnit.Library.Test.UnitTestGeneratorTests>();
        
        [TestInitialize()]
        [System.Diagnostics.CodeAnalysis.SuppressMessage(""Microsoft.Reliability"", ""CA2000:Dispose objects before losing scope"", Justification=""proxy should not be disposed"")]
        public void InitializeTest()
        {
            System.Threading.Monitor.Enter(unitTestGeneratorTestsProxyTable);
            try
            {
                unitTestGeneratorTestsProxyTable.TryGetValue(System.Threading.Thread.CurrentThread.ManagedThreadId, out unitTestGeneratorTestsClient);
                if (((unitTestGeneratorTestsClient == null) 
                            || (((System.ServiceModel.ICommunicationObject)(unitTestGeneratorTestsClient)).State == System.ServiceModel.CommunicationState.Faulted)))
                {
                    // The following line may need to be customised to select the appropriate binding from the configuration file
                    System.ServiceModel.ChannelFactory<Microsoft.WcfUnit.Library.Test.UnitTestGeneratorTests> unitTestGeneratorTestsFactory = new System.ServiceModel.ChannelFactory<Microsoft.WcfUnit.Library.Test.UnitTestGeneratorTests>();
                    unitTestGeneratorTestsClient = unitTestGeneratorTestsFactory.CreateChannel();
                    ((System.ServiceModel.ICommunicationObject)(unitTestGeneratorTestsClient)).Open();
                    unitTestGeneratorTestsProxyTable[System.Threading.Thread.CurrentThread.ManagedThreadId] = unitTestGeneratorTestsClient;
                }
            }
            finally
            {
                System.Threading.Monitor.Exit(unitTestGeneratorTestsProxyTable);
            }
        }
        
        private void CustomiseValueTypeTestMethod(ref int a)
        {
        }
    }
}
");
        }

        [TestMethod]
        public void UTGNoCommentGeneratedWhenNullPassedForComment()
        {
            UnitTestGenerator utg = CreateUnitTestGenerator();
            utg.GenerateServiceCall(
                null,
                this.GetType().GetMethod("ValueTypeTestMethod"),
                new CallParameterInfo[] { new CallParameterInfo("a", typeof(int), FieldDirection.In, 1) },
                null);
            CheckCode(utg,
@"//------------------------------------------------------------------------------
// <auto-generated>
//     This code was generated by a tool.
//     Runtime Version:2.0.50727.1433
//
//     Changes to this file may cause incorrect behavior and will be lost if
//     the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------

namespace TestNamespace
{
    using Microsoft.VisualStudio.TestTools.UnitTesting;
    using System.Collections.Generic;
    
    
    [TestClass()]
    [System.Diagnostics.CodeAnalysis.SuppressMessage(""Microsoft.Design"", ""CA1001:TypesThatOwnDisposableFieldsShouldBeDisposable"", Justification=""proxy should not be disposed"")]
    public partial class TestClass
    {
        
        private TestContext _testContext;
        
        private Microsoft.WcfUnit.Library.Test.UnitTestGeneratorTests unitTestGeneratorTestsClient;
        
        public TestContext TestContext
        {
            get
            {
                return this._testContext;
            }
            set
            {
                this._testContext = value;
            }
        }
        
        [TestMethod()]
        public void TestScenario()
        {
            this.ValueTypeTestMethod();
        }
        
        private void ValueTypeTestMethod()
        {
            int a = 1;
            this.CustomiseValueTypeTestMethod(ref a);
            _testContext.BeginTimer(""TestScenario_ValueTypeTestMethod"");
            try
            {
                unitTestGeneratorTestsClient.ValueTypeTestMethod(a);
            }
            finally
            {
                _testContext.EndTimer(""TestScenario_ValueTypeTestMethod"");
            }
        }
    }
}
",
@"//------------------------------------------------------------------------------
// <auto-generated>
//     This code was generated by a tool.
//     Runtime Version:2.0.50727.1433
//
//     Changes to this file may cause incorrect behavior and will be lost if
//     the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------

namespace TestNamespace
{
    using Microsoft.VisualStudio.TestTools.UnitTesting;
    using System.Collections.Generic;
    
    
    public partial class TestClass
    {
        
        private static Dictionary<int, Microsoft.WcfUnit.Library.Test.UnitTestGeneratorTests> unitTestGeneratorTestsProxyTable = new Dictionary<int, Microsoft.WcfUnit.Library.Test.UnitTestGeneratorTests>();
        
        [TestInitialize()]
        [System.Diagnostics.CodeAnalysis.SuppressMessage(""Microsoft.Reliability"", ""CA2000:Dispose objects before losing scope"", Justification=""proxy should not be disposed"")]
        public void InitializeTest()
        {
            System.Threading.Monitor.Enter(unitTestGeneratorTestsProxyTable);
            try
            {
                unitTestGeneratorTestsProxyTable.TryGetValue(System.Threading.Thread.CurrentThread.ManagedThreadId, out unitTestGeneratorTestsClient);
                if (((unitTestGeneratorTestsClient == null) 
                            || (((System.ServiceModel.ICommunicationObject)(unitTestGeneratorTestsClient)).State == System.ServiceModel.CommunicationState.Faulted)))
                {
                    // The following line may need to be customised to select the appropriate binding from the configuration file
                    System.ServiceModel.ChannelFactory<Microsoft.WcfUnit.Library.Test.UnitTestGeneratorTests> unitTestGeneratorTestsFactory = new System.ServiceModel.ChannelFactory<Microsoft.WcfUnit.Library.Test.UnitTestGeneratorTests>();
                    unitTestGeneratorTestsClient = unitTestGeneratorTestsFactory.CreateChannel();
                    ((System.ServiceModel.ICommunicationObject)(unitTestGeneratorTestsClient)).Open();
                    unitTestGeneratorTestsProxyTable[System.Threading.Thread.CurrentThread.ManagedThreadId] = unitTestGeneratorTestsClient;
                }
            }
            finally
            {
                System.Threading.Monitor.Exit(unitTestGeneratorTestsProxyTable);
            }
        }
        
        private void CustomiseValueTypeTestMethod(ref int a)
        {
        }
    }
}
");
        }

        [TestMethod]
        public void UTGNoCommentGeneratedWhenEmptyStringPassedForComment()
        {
            UnitTestGenerator utg = CreateUnitTestGenerator();
            utg.GenerateServiceCall(
                null,
                this.GetType().GetMethod("ValueTypeTestMethod"),
                new CallParameterInfo[] { new CallParameterInfo("a", typeof(int), FieldDirection.In, 1) },
                string.Empty);
            CheckCode(utg,
@"//------------------------------------------------------------------------------
// <auto-generated>
//     This code was generated by a tool.
//     Runtime Version:2.0.50727.1433
//
//     Changes to this file may cause incorrect behavior and will be lost if
//     the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------

namespace TestNamespace
{
    using Microsoft.VisualStudio.TestTools.UnitTesting;
    using System.Collections.Generic;
    
    
    [TestClass()]
    [System.Diagnostics.CodeAnalysis.SuppressMessage(""Microsoft.Design"", ""CA1001:TypesThatOwnDisposableFieldsShouldBeDisposable"", Justification=""proxy should not be disposed"")]
    public partial class TestClass
    {
        
        private TestContext _testContext;
        
        private Microsoft.WcfUnit.Library.Test.UnitTestGeneratorTests unitTestGeneratorTestsClient;
        
        public TestContext TestContext
        {
            get
            {
                return this._testContext;
            }
            set
            {
                this._testContext = value;
            }
        }
        
        [TestMethod()]
        public void TestScenario()
        {
            this.ValueTypeTestMethod();
        }
        
        private void ValueTypeTestMethod()
        {
            int a = 1;
            this.CustomiseValueTypeTestMethod(ref a);
            _testContext.BeginTimer(""TestScenario_ValueTypeTestMethod"");
            try
            {
                unitTestGeneratorTestsClient.ValueTypeTestMethod(a);
            }
            finally
            {
                _testContext.EndTimer(""TestScenario_ValueTypeTestMethod"");
            }
        }
    }
}
",
@"//------------------------------------------------------------------------------
// <auto-generated>
//     This code was generated by a tool.
//     Runtime Version:2.0.50727.1433
//
//     Changes to this file may cause incorrect behavior and will be lost if
//     the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------

namespace TestNamespace
{
    using Microsoft.VisualStudio.TestTools.UnitTesting;
    using System.Collections.Generic;
    
    
    public partial class TestClass
    {
        
        private static Dictionary<int, Microsoft.WcfUnit.Library.Test.UnitTestGeneratorTests> unitTestGeneratorTestsProxyTable = new Dictionary<int, Microsoft.WcfUnit.Library.Test.UnitTestGeneratorTests>();
        
        [TestInitialize()]
        [System.Diagnostics.CodeAnalysis.SuppressMessage(""Microsoft.Reliability"", ""CA2000:Dispose objects before losing scope"", Justification=""proxy should not be disposed"")]
        public void InitializeTest()
        {
            System.Threading.Monitor.Enter(unitTestGeneratorTestsProxyTable);
            try
            {
                unitTestGeneratorTestsProxyTable.TryGetValue(System.Threading.Thread.CurrentThread.ManagedThreadId, out unitTestGeneratorTestsClient);
                if (((unitTestGeneratorTestsClient == null) 
                            || (((System.ServiceModel.ICommunicationObject)(unitTestGeneratorTestsClient)).State == System.ServiceModel.CommunicationState.Faulted)))
                {
                    // The following line may need to be customised to select the appropriate binding from the configuration file
                    System.ServiceModel.ChannelFactory<Microsoft.WcfUnit.Library.Test.UnitTestGeneratorTests> unitTestGeneratorTestsFactory = new System.ServiceModel.ChannelFactory<Microsoft.WcfUnit.Library.Test.UnitTestGeneratorTests>();
                    unitTestGeneratorTestsClient = unitTestGeneratorTestsFactory.CreateChannel();
                    ((System.ServiceModel.ICommunicationObject)(unitTestGeneratorTestsClient)).Open();
                    unitTestGeneratorTestsProxyTable[System.Threading.Thread.CurrentThread.ManagedThreadId] = unitTestGeneratorTestsClient;
                }
            }
            finally
            {
                System.Threading.Monitor.Exit(unitTestGeneratorTestsProxyTable);
            }
        }
        
        private void CustomiseValueTypeTestMethod(ref int a)
        {
        }
    }
}
");
        }

        public void StringTypeTestMethod(string a)
        {
        }

        [TestMethod]
        public void UTGStringTypeIsGeneratedAsARefParameterOnTheStub()
        {
            UnitTestGenerator utg = CreateUnitTestGenerator();
            utg.GenerateServiceCall(
                null,
                this.GetType().GetMethod("StringTypeTestMethod"),
                new CallParameterInfo[] { new CallParameterInfo("a", typeof(string), FieldDirection.In, string.Empty) },
                this.comment);
            CheckCode(utg,
@"//------------------------------------------------------------------------------
// <auto-generated>
//     This code was generated by a tool.
//     Runtime Version:2.0.50727.1433
//
//     Changes to this file may cause incorrect behavior and will be lost if
//     the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------

namespace TestNamespace
{
    using Microsoft.VisualStudio.TestTools.UnitTesting;
    using System.Collections.Generic;
    
    
    [TestClass()]
    [System.Diagnostics.CodeAnalysis.SuppressMessage(""Microsoft.Design"", ""CA1001:TypesThatOwnDisposableFieldsShouldBeDisposable"", Justification=""proxy should not be disposed"")]
    public partial class TestClass
    {
        
        private TestContext _testContext;
        
        private Microsoft.WcfUnit.Library.Test.UnitTestGeneratorTests unitTestGeneratorTestsClient;
        
        public TestContext TestContext
        {
            get
            {
                return this._testContext;
            }
            set
            {
                this._testContext = value;
            }
        }
        
        [TestMethod()]
        public void TestScenario()
        {
            // 11/15/2007 00:00:00
            this.StringTypeTestMethod();
        }
        
        private void StringTypeTestMethod()
        {
            string a = """";
            this.CustomiseStringTypeTestMethod(ref a);
            _testContext.BeginTimer(""TestScenario_StringTypeTestMethod"");
            try
            {
                unitTestGeneratorTestsClient.StringTypeTestMethod(a);
            }
            finally
            {
                _testContext.EndTimer(""TestScenario_StringTypeTestMethod"");
            }
        }
    }
}
",
@"//------------------------------------------------------------------------------
// <auto-generated>
//     This code was generated by a tool.
//     Runtime Version:2.0.50727.1433
//
//     Changes to this file may cause incorrect behavior and will be lost if
//     the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------

namespace TestNamespace
{
    using Microsoft.VisualStudio.TestTools.UnitTesting;
    using System.Collections.Generic;
    
    
    public partial class TestClass
    {
        
        private static Dictionary<int, Microsoft.WcfUnit.Library.Test.UnitTestGeneratorTests> unitTestGeneratorTestsProxyTable = new Dictionary<int, Microsoft.WcfUnit.Library.Test.UnitTestGeneratorTests>();
        
        [TestInitialize()]
        [System.Diagnostics.CodeAnalysis.SuppressMessage(""Microsoft.Reliability"", ""CA2000:Dispose objects before losing scope"", Justification=""proxy should not be disposed"")]
        public void InitializeTest()
        {
            System.Threading.Monitor.Enter(unitTestGeneratorTestsProxyTable);
            try
            {
                unitTestGeneratorTestsProxyTable.TryGetValue(System.Threading.Thread.CurrentThread.ManagedThreadId, out unitTestGeneratorTestsClient);
                if (((unitTestGeneratorTestsClient == null) 
                            || (((System.ServiceModel.ICommunicationObject)(unitTestGeneratorTestsClient)).State == System.ServiceModel.CommunicationState.Faulted)))
                {
                    // The following line may need to be customised to select the appropriate binding from the configuration file
                    System.ServiceModel.ChannelFactory<Microsoft.WcfUnit.Library.Test.UnitTestGeneratorTests> unitTestGeneratorTestsFactory = new System.ServiceModel.ChannelFactory<Microsoft.WcfUnit.Library.Test.UnitTestGeneratorTests>();
                    unitTestGeneratorTestsClient = unitTestGeneratorTestsFactory.CreateChannel();
                    ((System.ServiceModel.ICommunicationObject)(unitTestGeneratorTestsClient)).Open();
                    unitTestGeneratorTestsProxyTable[System.Threading.Thread.CurrentThread.ManagedThreadId] = unitTestGeneratorTestsClient;
                }
            }
            finally
            {
                System.Threading.Monitor.Exit(unitTestGeneratorTestsProxyTable);
            }
        }
        
        private void CustomiseStringTypeTestMethod(ref string a)
        {
        }
    }
}
");
        }

        public void ReferenceTypeTestMethod(UTGTestReferenceType a)
        {
        }

        // TODO: this test does not do what the name suggests.
        [TestMethod]
        public void UTGReferenceTypeIsGeneratedAsARefParameterOnTheStub()
        {
            UnitTestGenerator utg = CreateUnitTestGenerator();
            utg.GenerateServiceCall(
                null,
                this.GetType().GetMethod("ReferenceTypeTestMethod"),
                new CallParameterInfo[] { new CallParameterInfo("a", typeof(UTGTestReferenceType), FieldDirection.In, null) },
                this.comment);
            CheckCode(utg,
@"//------------------------------------------------------------------------------
// <auto-generated>
//     This code was generated by a tool.
//     Runtime Version:2.0.50727.1433
//
//     Changes to this file may cause incorrect behavior and will be lost if
//     the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------

namespace TestNamespace
{
    using Microsoft.VisualStudio.TestTools.UnitTesting;
    using System.Collections.Generic;
    
    
    [TestClass()]
    [System.Diagnostics.CodeAnalysis.SuppressMessage(""Microsoft.Design"", ""CA1001:TypesThatOwnDisposableFieldsShouldBeDisposable"", Justification=""proxy should not be disposed"")]
    public partial class TestClass
    {
        
        private TestContext _testContext;
        
        private Microsoft.WcfUnit.Library.Test.UnitTestGeneratorTests unitTestGeneratorTestsClient;
        
        public TestContext TestContext
        {
            get
            {
                return this._testContext;
            }
            set
            {
                this._testContext = value;
            }
        }
        
        [TestMethod()]
        public void TestScenario()
        {
            // 11/15/2007 00:00:00
            this.ReferenceTypeTestMethod();
        }
        
        private void ReferenceTypeTestMethod()
        {
            Microsoft.WcfUnit.Library.Test.TestContracts.UTGTestReferenceType a = null;
            this.CustomiseReferenceTypeTestMethod(a);
            _testContext.BeginTimer(""TestScenario_ReferenceTypeTestMethod"");
            try
            {
                unitTestGeneratorTestsClient.ReferenceTypeTestMethod(a);
            }
            finally
            {
                _testContext.EndTimer(""TestScenario_ReferenceTypeTestMethod"");
            }
        }
    }
}
",
@"//------------------------------------------------------------------------------
// <auto-generated>
//     This code was generated by a tool.
//     Runtime Version:2.0.50727.1433
//
//     Changes to this file may cause incorrect behavior and will be lost if
//     the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------

namespace TestNamespace
{
    using Microsoft.VisualStudio.TestTools.UnitTesting;
    using System.Collections.Generic;
    
    
    public partial class TestClass
    {
        
        private static Dictionary<int, Microsoft.WcfUnit.Library.Test.UnitTestGeneratorTests> unitTestGeneratorTestsProxyTable = new Dictionary<int, Microsoft.WcfUnit.Library.Test.UnitTestGeneratorTests>();
        
        [TestInitialize()]
        [System.Diagnostics.CodeAnalysis.SuppressMessage(""Microsoft.Reliability"", ""CA2000:Dispose objects before losing scope"", Justification=""proxy should not be disposed"")]
        public void InitializeTest()
        {
            System.Threading.Monitor.Enter(unitTestGeneratorTestsProxyTable);
            try
            {
                unitTestGeneratorTestsProxyTable.TryGetValue(System.Threading.Thread.CurrentThread.ManagedThreadId, out unitTestGeneratorTestsClient);
                if (((unitTestGeneratorTestsClient == null) 
                            || (((System.ServiceModel.ICommunicationObject)(unitTestGeneratorTestsClient)).State == System.ServiceModel.CommunicationState.Faulted)))
                {
                    // The following line may need to be customised to select the appropriate binding from the configuration file
                    System.ServiceModel.ChannelFactory<Microsoft.WcfUnit.Library.Test.UnitTestGeneratorTests> unitTestGeneratorTestsFactory = new System.ServiceModel.ChannelFactory<Microsoft.WcfUnit.Library.Test.UnitTestGeneratorTests>();
                    unitTestGeneratorTestsClient = unitTestGeneratorTestsFactory.CreateChannel();
                    ((System.ServiceModel.ICommunicationObject)(unitTestGeneratorTestsClient)).Open();
                    unitTestGeneratorTestsProxyTable[System.Threading.Thread.CurrentThread.ManagedThreadId] = unitTestGeneratorTestsClient;
                }
            }
            finally
            {
                System.Threading.Monitor.Exit(unitTestGeneratorTestsProxyTable);
            }
        }
        
        private void CustomiseReferenceTypeTestMethod(Microsoft.WcfUnit.Library.Test.TestContracts.UTGTestReferenceType a)
        {
        }
    }
}
");
        }

        public void StreamTestMethod(Stream input)
        {
        }

        [TestMethod]
        public void UTGStreamIsNotNewedAndPassedAsOutToTheStub()
        {
            UnitTestGenerator utg = CreateUnitTestGenerator();
            utg.GenerateServiceCall(
                null,
                this.GetType().GetMethod("StreamTestMethod"),
                new CallParameterInfo[] { new CallParameterInfo("input", typeof(Stream), FieldDirection.In, null) },
                this.comment);
            CheckCode(utg,
@"//------------------------------------------------------------------------------
// <auto-generated>
//     This code was generated by a tool.
//     Runtime Version:2.0.50727.1433
//
//     Changes to this file may cause incorrect behavior and will be lost if
//     the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------

namespace TestNamespace
{
    using Microsoft.VisualStudio.TestTools.UnitTesting;
    using System.Collections.Generic;
    
    
    [TestClass()]
    [System.Diagnostics.CodeAnalysis.SuppressMessage(""Microsoft.Design"", ""CA1001:TypesThatOwnDisposableFieldsShouldBeDisposable"", Justification=""proxy should not be disposed"")]
    public partial class TestClass
    {
        
        private TestContext _testContext;
        
        private Microsoft.WcfUnit.Library.Test.UnitTestGeneratorTests unitTestGeneratorTestsClient;
        
        public TestContext TestContext
        {
            get
            {
                return this._testContext;
            }
            set
            {
                this._testContext = value;
            }
        }
        
        [TestMethod()]
        public void TestScenario()
        {
            // 11/15/2007 00:00:00
            this.StreamTestMethod();
        }
        
        private void StreamTestMethod()
        {
            System.IO.Stream input = null;
            this.CustomiseStreamTestMethod(out input);
            _testContext.BeginTimer(""TestScenario_StreamTestMethod"");
            try
            {
                unitTestGeneratorTestsClient.StreamTestMethod(input);
            }
            finally
            {
                _testContext.EndTimer(""TestScenario_StreamTestMethod"");
            }
        }
    }
}
",
@"//------------------------------------------------------------------------------
// <auto-generated>
//     This code was generated by a tool.
//     Runtime Version:2.0.50727.1433
//
//     Changes to this file may cause incorrect behavior and will be lost if
//     the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------

namespace TestNamespace
{
    using Microsoft.VisualStudio.TestTools.UnitTesting;
    using System.Collections.Generic;
    
    
    public partial class TestClass
    {
        
        private static Dictionary<int, Microsoft.WcfUnit.Library.Test.UnitTestGeneratorTests> unitTestGeneratorTestsProxyTable = new Dictionary<int, Microsoft.WcfUnit.Library.Test.UnitTestGeneratorTests>();
        
        [TestInitialize()]
        [System.Diagnostics.CodeAnalysis.SuppressMessage(""Microsoft.Reliability"", ""CA2000:Dispose objects before losing scope"", Justification=""proxy should not be disposed"")]
        public void InitializeTest()
        {
            System.Threading.Monitor.Enter(unitTestGeneratorTestsProxyTable);
            try
            {
                unitTestGeneratorTestsProxyTable.TryGetValue(System.Threading.Thread.CurrentThread.ManagedThreadId, out unitTestGeneratorTestsClient);
                if (((unitTestGeneratorTestsClient == null) 
                            || (((System.ServiceModel.ICommunicationObject)(unitTestGeneratorTestsClient)).State == System.ServiceModel.CommunicationState.Faulted)))
                {
                    // The following line may need to be customised to select the appropriate binding from the configuration file
                    System.ServiceModel.ChannelFactory<Microsoft.WcfUnit.Library.Test.UnitTestGeneratorTests> unitTestGeneratorTestsFactory = new System.ServiceModel.ChannelFactory<Microsoft.WcfUnit.Library.Test.UnitTestGeneratorTests>();
                    unitTestGeneratorTestsClient = unitTestGeneratorTestsFactory.CreateChannel();
                    ((System.ServiceModel.ICommunicationObject)(unitTestGeneratorTestsClient)).Open();
                    unitTestGeneratorTestsProxyTable[System.Threading.Thread.CurrentThread.ManagedThreadId] = unitTestGeneratorTestsClient;
                }
            }
            finally
            {
                System.Threading.Monitor.Exit(unitTestGeneratorTestsProxyTable);
            }
        }
        
        private void CustomiseStreamTestMethod(out System.IO.Stream input)
        {
            input = default(System.IO.Stream);
        }
    }
}
");
        }

        public void MemoryStreamTestMethod(MemoryStream input)
        {
        }

        [TestMethod]
        public void UTGMemoryStreamIsNotNewedAndPassedAsOutToTheStub()
        {
            UnitTestGenerator utg = CreateUnitTestGenerator();
            utg.GenerateServiceCall(
                null,
                this.GetType().GetMethod("MemoryStreamTestMethod"),
                new CallParameterInfo[] { new CallParameterInfo("input", typeof(MemoryStream), FieldDirection.In, null) },
                this.comment);
            CheckCode(utg,
@"//------------------------------------------------------------------------------
// <auto-generated>
//     This code was generated by a tool.
//     Runtime Version:2.0.50727.1433
//
//     Changes to this file may cause incorrect behavior and will be lost if
//     the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------

namespace TestNamespace
{
    using Microsoft.VisualStudio.TestTools.UnitTesting;
    using System.Collections.Generic;
    
    
    [TestClass()]
    [System.Diagnostics.CodeAnalysis.SuppressMessage(""Microsoft.Design"", ""CA1001:TypesThatOwnDisposableFieldsShouldBeDisposable"", Justification=""proxy should not be disposed"")]
    public partial class TestClass
    {
        
        private TestContext _testContext;
        
        private Microsoft.WcfUnit.Library.Test.UnitTestGeneratorTests unitTestGeneratorTestsClient;
        
        public TestContext TestContext
        {
            get
            {
                return this._testContext;
            }
            set
            {
                this._testContext = value;
            }
        }
        
        [TestMethod()]
        public void TestScenario()
        {
            // 11/15/2007 00:00:00
            this.MemoryStreamTestMethod();
        }
        
        private void MemoryStreamTestMethod()
        {
            System.IO.MemoryStream input = null;
            this.CustomiseMemoryStreamTestMethod(out input);
            _testContext.BeginTimer(""TestScenario_MemoryStreamTestMethod"");
            try
            {
                unitTestGeneratorTestsClient.MemoryStreamTestMethod(input);
            }
            finally
            {
                _testContext.EndTimer(""TestScenario_MemoryStreamTestMethod"");
            }
        }
    }
}
",
@"//------------------------------------------------------------------------------
// <auto-generated>
//     This code was generated by a tool.
//     Runtime Version:2.0.50727.1433
//
//     Changes to this file may cause incorrect behavior and will be lost if
//     the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------

namespace TestNamespace
{
    using Microsoft.VisualStudio.TestTools.UnitTesting;
    using System.Collections.Generic;
    
    
    public partial class TestClass
    {
        
        private static Dictionary<int, Microsoft.WcfUnit.Library.Test.UnitTestGeneratorTests> unitTestGeneratorTestsProxyTable = new Dictionary<int, Microsoft.WcfUnit.Library.Test.UnitTestGeneratorTests>();
        
        [TestInitialize()]
        [System.Diagnostics.CodeAnalysis.SuppressMessage(""Microsoft.Reliability"", ""CA2000:Dispose objects before losing scope"", Justification=""proxy should not be disposed"")]
        public void InitializeTest()
        {
            System.Threading.Monitor.Enter(unitTestGeneratorTestsProxyTable);
            try
            {
                unitTestGeneratorTestsProxyTable.TryGetValue(System.Threading.Thread.CurrentThread.ManagedThreadId, out unitTestGeneratorTestsClient);
                if (((unitTestGeneratorTestsClient == null) 
                            || (((System.ServiceModel.ICommunicationObject)(unitTestGeneratorTestsClient)).State == System.ServiceModel.CommunicationState.Faulted)))
                {
                    // The following line may need to be customised to select the appropriate binding from the configuration file
                    System.ServiceModel.ChannelFactory<Microsoft.WcfUnit.Library.Test.UnitTestGeneratorTests> unitTestGeneratorTestsFactory = new System.ServiceModel.ChannelFactory<Microsoft.WcfUnit.Library.Test.UnitTestGeneratorTests>();
                    unitTestGeneratorTestsClient = unitTestGeneratorTestsFactory.CreateChannel();
                    ((System.ServiceModel.ICommunicationObject)(unitTestGeneratorTestsClient)).Open();
                    unitTestGeneratorTestsProxyTable[System.Threading.Thread.CurrentThread.ManagedThreadId] = unitTestGeneratorTestsClient;
                }
            }
            finally
            {
                System.Threading.Monitor.Exit(unitTestGeneratorTestsProxyTable);
            }
        }
        
        private void CustomiseMemoryStreamTestMethod(out System.IO.MemoryStream input)
        {
            input = default(System.IO.MemoryStream);
        }
    }
}
");
        }

        public void BufferedUnwrappedMessageWithStreamMethod(BufferedUnwrappedMessageWithStream input)
        {
        }

        [TestMethod]
        public void UTGMessageContractWithStream()
        {
            BufferedUnwrappedMessageWithStream value = new BufferedUnwrappedMessageWithStream();
            value.Header = 1;
            value.Body1 = new MemoryStream();
            UnitTestGenerator utg = CreateUnitTestGenerator();
            utg.GenerateServiceCall(
                null,
                this.GetType().GetMethod("BufferedUnwrappedMessageWithStreamMethod"),
                new CallParameterInfo[] { new CallParameterInfo("a", typeof(BufferedUnwrappedMessageWithStream), FieldDirection.In, value) },
                this.comment);
            CheckCode(utg,
@"//------------------------------------------------------------------------------
// <auto-generated>
//     This code was generated by a tool.
//     Runtime Version:2.0.50727.1433
//
//     Changes to this file may cause incorrect behavior and will be lost if
//     the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------

namespace TestNamespace
{
    using Microsoft.VisualStudio.TestTools.UnitTesting;
    using System.Collections.Generic;
    
    
    [TestClass()]
    [System.Diagnostics.CodeAnalysis.SuppressMessage(""Microsoft.Design"", ""CA1001:TypesThatOwnDisposableFieldsShouldBeDisposable"", Justification=""proxy should not be disposed"")]
    public partial class TestClass
    {
        
        private TestContext _testContext;
        
        private Microsoft.WcfUnit.Library.Test.UnitTestGeneratorTests unitTestGeneratorTestsClient;
        
        public TestContext TestContext
        {
            get
            {
                return this._testContext;
            }
            set
            {
                this._testContext = value;
            }
        }
        
        [TestMethod()]
        public void TestScenario()
        {
            // 11/15/2007 00:00:00
            this.BufferedUnwrappedMessageWithStreamMethod();
        }
        
        private void BufferedUnwrappedMessageWithStreamMethod()
        {
            Contracts.BufferedUnwrappedMessageWithStream a = new Contracts.BufferedUnwrappedMessageWithStream();
            a.Header = 1;
            a.Body1 = null;
            this.CustomiseBufferedUnwrappedMessageWithStreamMethod(a);
            _testContext.BeginTimer(""TestScenario_BufferedUnwrappedMessageWithStreamMethod"");
            try
            {
                unitTestGeneratorTestsClient.BufferedUnwrappedMessageWithStreamMethod(a);
            }
            finally
            {
                _testContext.EndTimer(""TestScenario_BufferedUnwrappedMessageWithStreamMethod"");
            }
        }
    }
}
",
@"//------------------------------------------------------------------------------
// <auto-generated>
//     This code was generated by a tool.
//     Runtime Version:2.0.50727.1433
//
//     Changes to this file may cause incorrect behavior and will be lost if
//     the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------

namespace TestNamespace
{
    using Microsoft.VisualStudio.TestTools.UnitTesting;
    using System.Collections.Generic;
    
    
    public partial class TestClass
    {
        
        private static Dictionary<int, Microsoft.WcfUnit.Library.Test.UnitTestGeneratorTests> unitTestGeneratorTestsProxyTable = new Dictionary<int, Microsoft.WcfUnit.Library.Test.UnitTestGeneratorTests>();
        
        [TestInitialize()]
        [System.Diagnostics.CodeAnalysis.SuppressMessage(""Microsoft.Reliability"", ""CA2000:Dispose objects before losing scope"", Justification=""proxy should not be disposed"")]
        public void InitializeTest()
        {
            System.Threading.Monitor.Enter(unitTestGeneratorTestsProxyTable);
            try
            {
                unitTestGeneratorTestsProxyTable.TryGetValue(System.Threading.Thread.CurrentThread.ManagedThreadId, out unitTestGeneratorTestsClient);
                if (((unitTestGeneratorTestsClient == null) 
                            || (((System.ServiceModel.ICommunicationObject)(unitTestGeneratorTestsClient)).State == System.ServiceModel.CommunicationState.Faulted)))
                {
                    // The following line may need to be customised to select the appropriate binding from the configuration file
                    System.ServiceModel.ChannelFactory<Microsoft.WcfUnit.Library.Test.UnitTestGeneratorTests> unitTestGeneratorTestsFactory = new System.ServiceModel.ChannelFactory<Microsoft.WcfUnit.Library.Test.UnitTestGeneratorTests>();
                    unitTestGeneratorTestsClient = unitTestGeneratorTestsFactory.CreateChannel();
                    ((System.ServiceModel.ICommunicationObject)(unitTestGeneratorTestsClient)).Open();
                    unitTestGeneratorTestsProxyTable[System.Threading.Thread.CurrentThread.ManagedThreadId] = unitTestGeneratorTestsClient;
                }
            }
            finally
            {
                System.Threading.Monitor.Exit(unitTestGeneratorTestsProxyTable);
            }
        }
        
        private void CustomiseBufferedUnwrappedMessageWithStreamMethod(Contracts.BufferedUnwrappedMessageWithStream a)
        {
        }
    }
}
");
        }

        public void BufferedUnwrappedMessageWithMemoryStreamMethod(BufferedUnwrappedMessageWithMemoryStream input)
        {
        }

        [TestMethod]
        public void UTGMessageContractWithMemoryStream()
        {
            BufferedUnwrappedMessageWithMemoryStream value = new BufferedUnwrappedMessageWithMemoryStream();
            value.Header = 1;
            value.Body2 = new MemoryStream();
            UnitTestGenerator utg = CreateUnitTestGenerator();
            utg.GenerateServiceCall(
                null,
                this.GetType().GetMethod("BufferedUnwrappedMessageWithMemoryStreamMethod"),
                new CallParameterInfo[] { new CallParameterInfo("a", typeof(BufferedUnwrappedMessageWithMemoryStream), FieldDirection.In, value) },
                this.comment);
            CheckCode(utg,
@"//------------------------------------------------------------------------------
// <auto-generated>
//     This code was generated by a tool.
//     Runtime Version:2.0.50727.1433
//
//     Changes to this file may cause incorrect behavior and will be lost if
//     the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------

namespace TestNamespace
{
    using Microsoft.VisualStudio.TestTools.UnitTesting;
    using System.Collections.Generic;
    
    
    [TestClass()]
    [System.Diagnostics.CodeAnalysis.SuppressMessage(""Microsoft.Design"", ""CA1001:TypesThatOwnDisposableFieldsShouldBeDisposable"", Justification=""proxy should not be disposed"")]
    public partial class TestClass
    {
        
        private TestContext _testContext;
        
        private Microsoft.WcfUnit.Library.Test.UnitTestGeneratorTests unitTestGeneratorTestsClient;
        
        public TestContext TestContext
        {
            get
            {
                return this._testContext;
            }
            set
            {
                this._testContext = value;
            }
        }
        
        [TestMethod()]
        public void TestScenario()
        {
            // 11/15/2007 00:00:00
            this.BufferedUnwrappedMessageWithMemoryStreamMethod();
        }
        
        private void BufferedUnwrappedMessageWithMemoryStreamMethod()
        {
            Contracts.BufferedUnwrappedMessageWithMemoryStream a = new Contracts.BufferedUnwrappedMessageWithMemoryStream();
            a.Header = 1;
            a.Body2 = new System.IO.MemoryStream();
            this.CustomiseBufferedUnwrappedMessageWithMemoryStreamMethod(a);
            _testContext.BeginTimer(""TestScenario_BufferedUnwrappedMessageWithMemoryStreamMethod"");
            try
            {
                unitTestGeneratorTestsClient.BufferedUnwrappedMessageWithMemoryStreamMethod(a);
            }
            finally
            {
                _testContext.EndTimer(""TestScenario_BufferedUnwrappedMessageWithMemoryStreamMethod"");
            }
        }
    }
}
",
@"//------------------------------------------------------------------------------
// <auto-generated>
//     This code was generated by a tool.
//     Runtime Version:2.0.50727.1433
//
//     Changes to this file may cause incorrect behavior and will be lost if
//     the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------

namespace TestNamespace
{
    using Microsoft.VisualStudio.TestTools.UnitTesting;
    using System.Collections.Generic;
    
    
    public partial class TestClass
    {
        
        private static Dictionary<int, Microsoft.WcfUnit.Library.Test.UnitTestGeneratorTests> unitTestGeneratorTestsProxyTable = new Dictionary<int, Microsoft.WcfUnit.Library.Test.UnitTestGeneratorTests>();
        
        [TestInitialize()]
        [System.Diagnostics.CodeAnalysis.SuppressMessage(""Microsoft.Reliability"", ""CA2000:Dispose objects before losing scope"", Justification=""proxy should not be disposed"")]
        public void InitializeTest()
        {
            System.Threading.Monitor.Enter(unitTestGeneratorTestsProxyTable);
            try
            {
                unitTestGeneratorTestsProxyTable.TryGetValue(System.Threading.Thread.CurrentThread.ManagedThreadId, out unitTestGeneratorTestsClient);
                if (((unitTestGeneratorTestsClient == null) 
                            || (((System.ServiceModel.ICommunicationObject)(unitTestGeneratorTestsClient)).State == System.ServiceModel.CommunicationState.Faulted)))
                {
                    // The following line may need to be customised to select the appropriate binding from the configuration file
                    System.ServiceModel.ChannelFactory<Microsoft.WcfUnit.Library.Test.UnitTestGeneratorTests> unitTestGeneratorTestsFactory = new System.ServiceModel.ChannelFactory<Microsoft.WcfUnit.Library.Test.UnitTestGeneratorTests>();
                    unitTestGeneratorTestsClient = unitTestGeneratorTestsFactory.CreateChannel();
                    ((System.ServiceModel.ICommunicationObject)(unitTestGeneratorTestsClient)).Open();
                    unitTestGeneratorTestsProxyTable[System.Threading.Thread.CurrentThread.ManagedThreadId] = unitTestGeneratorTestsClient;
                }
            }
            finally
            {
                System.Threading.Monitor.Exit(unitTestGeneratorTestsProxyTable);
            }
        }
        
        private void CustomiseBufferedUnwrappedMessageWithMemoryStreamMethod(Contracts.BufferedUnwrappedMessageWithMemoryStream a)
        {
        }
    }
}
");
        }

        public void ValueParameterTestMethod(int a)
        {
        }

        // This test covers the situation where we have a service-side trace with non stream parameters, the
        // trace in this case has no data and the deserializer sets its value to null in this case.
        [TestMethod]
        public void UTGValueTypeIsGeneratedAsAnOutParameterOnTheStubWhenThereIsNoInitialValue()
        {
            UnitTestGenerator utg = CreateUnitTestGenerator();
            utg.GenerateServiceCall(
                null,
                this.GetType().GetMethod("ValueParameterTestMethod"),
                new CallParameterInfo[] { new CallParameterInfo("a", typeof(int), FieldDirection.In, null) },
                this.comment);
            CheckCode(utg,
@"//------------------------------------------------------------------------------
// <auto-generated>
//     This code was generated by a tool.
//     Runtime Version:2.0.50727.1433
//
//     Changes to this file may cause incorrect behavior and will be lost if
//     the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------

namespace TestNamespace
{
    using Microsoft.VisualStudio.TestTools.UnitTesting;
    using System.Collections.Generic;
    
    
    [TestClass()]
    [System.Diagnostics.CodeAnalysis.SuppressMessage(""Microsoft.Design"", ""CA1001:TypesThatOwnDisposableFieldsShouldBeDisposable"", Justification=""proxy should not be disposed"")]
    public partial class TestClass
    {
        
        private TestContext _testContext;
        
        private Microsoft.WcfUnit.Library.Test.UnitTestGeneratorTests unitTestGeneratorTestsClient;
        
        public TestContext TestContext
        {
            get
            {
                return this._testContext;
            }
            set
            {
                this._testContext = value;
            }
        }
        
        [TestMethod()]
        public void TestScenario()
        {
            // 11/15/2007 00:00:00
            this.ValueParameterTestMethod();
        }
        
        private void ValueParameterTestMethod()
        {
            int a;
            this.CustomiseValueParameterTestMethod(out a);
            _testContext.BeginTimer(""TestScenario_ValueParameterTestMethod"");
            try
            {
                unitTestGeneratorTestsClient.ValueParameterTestMethod(a);
            }
            finally
            {
                _testContext.EndTimer(""TestScenario_ValueParameterTestMethod"");
            }
        }
    }
}
",
@"//------------------------------------------------------------------------------
// <auto-generated>
//     This code was generated by a tool.
//     Runtime Version:2.0.50727.1433
//
//     Changes to this file may cause incorrect behavior and will be lost if
//     the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------

namespace TestNamespace
{
    using Microsoft.VisualStudio.TestTools.UnitTesting;
    using System.Collections.Generic;
    
    
    public partial class TestClass
    {
        
        private static Dictionary<int, Microsoft.WcfUnit.Library.Test.UnitTestGeneratorTests> unitTestGeneratorTestsProxyTable = new Dictionary<int, Microsoft.WcfUnit.Library.Test.UnitTestGeneratorTests>();
        
        [TestInitialize()]
        [System.Diagnostics.CodeAnalysis.SuppressMessage(""Microsoft.Reliability"", ""CA2000:Dispose objects before losing scope"", Justification=""proxy should not be disposed"")]
        public void InitializeTest()
        {
            System.Threading.Monitor.Enter(unitTestGeneratorTestsProxyTable);
            try
            {
                unitTestGeneratorTestsProxyTable.TryGetValue(System.Threading.Thread.CurrentThread.ManagedThreadId, out unitTestGeneratorTestsClient);
                if (((unitTestGeneratorTestsClient == null) 
                            || (((System.ServiceModel.ICommunicationObject)(unitTestGeneratorTestsClient)).State == System.ServiceModel.CommunicationState.Faulted)))
                {
                    // The following line may need to be customised to select the appropriate binding from the configuration file
                    System.ServiceModel.ChannelFactory<Microsoft.WcfUnit.Library.Test.UnitTestGeneratorTests> unitTestGeneratorTestsFactory = new System.ServiceModel.ChannelFactory<Microsoft.WcfUnit.Library.Test.UnitTestGeneratorTests>();
                    unitTestGeneratorTestsClient = unitTestGeneratorTestsFactory.CreateChannel();
                    ((System.ServiceModel.ICommunicationObject)(unitTestGeneratorTestsClient)).Open();
                    unitTestGeneratorTestsProxyTable[System.Threading.Thread.CurrentThread.ManagedThreadId] = unitTestGeneratorTestsClient;
                }
            }
            finally
            {
                System.Threading.Monitor.Exit(unitTestGeneratorTestsProxyTable);
            }
        }
        
        private void CustomiseValueParameterTestMethod(out int a)
        {
            a = default(int);
        }
    }
}
");
        }

        [TestMethod]
        public void UTGProxyIsNewedAndOpenedWhenThereIsAProxyClass()
        {
            UnitTestGenerator utg = CreateUnitTestGenerator();
            utg.GenerateServiceCall(
                typeof(UTGTestContractProxyCommObject).GetMethod("Operation"),
                typeof(IUTGTestContract).GetMethod("Operation"),
                new CallParameterInfo[] { },
                this.comment);
            CheckCode(utg,
@"//------------------------------------------------------------------------------
// <auto-generated>
//     This code was generated by a tool.
//     Runtime Version:2.0.50727.1433
//
//     Changes to this file may cause incorrect behavior and will be lost if
//     the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------

namespace TestNamespace
{
    using Microsoft.VisualStudio.TestTools.UnitTesting;
    using System.Collections.Generic;
    
    
    [TestClass()]
    [System.Diagnostics.CodeAnalysis.SuppressMessage(""Microsoft.Design"", ""CA1001:TypesThatOwnDisposableFieldsShouldBeDisposable"", Justification=""proxy should not be disposed"")]
    public partial class TestClass
    {
        
        private TestContext _testContext;
        
        private Microsoft.WcfUnit.Library.Test.TestContracts.IUTGTestContract utgTestContractClient;
        
        public TestContext TestContext
        {
            get
            {
                return this._testContext;
            }
            set
            {
                this._testContext = value;
            }
        }
        
        [TestMethod()]
        public void TestScenario()
        {
            // 11/15/2007 00:00:00
            this.Operation();
        }
        
        private void Operation()
        {
            _testContext.BeginTimer(""TestScenario_Operation"");
            try
            {
                utgTestContractClient.Operation();
            }
            finally
            {
                _testContext.EndTimer(""TestScenario_Operation"");
            }
        }
    }
}
",
@"//------------------------------------------------------------------------------
// <auto-generated>
//     This code was generated by a tool.
//     Runtime Version:2.0.50727.1433
//
//     Changes to this file may cause incorrect behavior and will be lost if
//     the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------

namespace TestNamespace
{
    using Microsoft.VisualStudio.TestTools.UnitTesting;
    using System.Collections.Generic;
    
    
    public partial class TestClass
    {
        
        private static Dictionary<int, Microsoft.WcfUnit.Library.Test.TestContracts.IUTGTestContract> utgTestContractProxyTable = new Dictionary<int, Microsoft.WcfUnit.Library.Test.TestContracts.IUTGTestContract>();
        
        [TestInitialize()]
        [System.Diagnostics.CodeAnalysis.SuppressMessage(""Microsoft.Reliability"", ""CA2000:Dispose objects before losing scope"", Justification=""proxy should not be disposed"")]
        public void InitializeTest()
        {
            System.Threading.Monitor.Enter(utgTestContractProxyTable);
            try
            {
                utgTestContractProxyTable.TryGetValue(System.Threading.Thread.CurrentThread.ManagedThreadId, out utgTestContractClient);
                if (((utgTestContractClient == null) 
                            || (((System.ServiceModel.ICommunicationObject)(utgTestContractClient)).State == System.ServiceModel.CommunicationState.Faulted)))
                {
                    // The following line may need to be customised to select the appropriate binding from the configuration file
                    utgTestContractClient = new Microsoft.WcfUnit.Library.Test.TestContracts.UTGTestContractProxyCommObject();
                    ((System.ServiceModel.ICommunicationObject)(utgTestContractClient)).Open();
                    utgTestContractProxyTable[System.Threading.Thread.CurrentThread.ManagedThreadId] = utgTestContractClient;
                }
            }
            finally
            {
                System.Threading.Monitor.Exit(utgTestContractProxyTable);
            }
        }
    }
}
");
        }

        [TestMethod]
        public void UTGProxyIsNewedAndOpenedWhenThereIsAProxyClassAndTheContractIsAlsoAClass()
        {
            UnitTestGenerator utg = CreateUnitTestGenerator();
            utg.GenerateServiceCall(
                typeof(UTGTestContractClassProxyCommObject).GetMethod("Operation"),
                typeof(UTGTestContractClass).GetMethod("Operation"),
                new CallParameterInfo[] { },
                this.comment);
            CheckCode(utg,
@"//------------------------------------------------------------------------------
// <auto-generated>
//     This code was generated by a tool.
//     Runtime Version:2.0.50727.1433
//
//     Changes to this file may cause incorrect behavior and will be lost if
//     the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------

namespace TestNamespace
{
    using Microsoft.VisualStudio.TestTools.UnitTesting;
    using System.Collections.Generic;
    
    
    [TestClass()]
    [System.Diagnostics.CodeAnalysis.SuppressMessage(""Microsoft.Design"", ""CA1001:TypesThatOwnDisposableFieldsShouldBeDisposable"", Justification=""proxy should not be disposed"")]
    public partial class TestClass
    {
        
        private TestContext _testContext;
        
        private Microsoft.WcfUnit.Library.Test.TestContracts.UTGTestContractClass utgTestContractClassClient;
        
        public TestContext TestContext
        {
            get
            {
                return this._testContext;
            }
            set
            {
                this._testContext = value;
            }
        }
        
        [TestMethod()]
        public void TestScenario()
        {
            // 11/15/2007 00:00:00
            this.Operation();
        }
        
        private void Operation()
        {
            _testContext.BeginTimer(""TestScenario_Operation"");
            try
            {
                utgTestContractClassClient.Operation();
            }
            finally
            {
                _testContext.EndTimer(""TestScenario_Operation"");
            }
        }
    }
}
",
@"//------------------------------------------------------------------------------
// <auto-generated>
//     This code was generated by a tool.
//     Runtime Version:2.0.50727.1433
//
//     Changes to this file may cause incorrect behavior and will be lost if
//     the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------

namespace TestNamespace
{
    using Microsoft.VisualStudio.TestTools.UnitTesting;
    using System.Collections.Generic;
    
    
    public partial class TestClass
    {
        
        private static Dictionary<int, Microsoft.WcfUnit.Library.Test.TestContracts.UTGTestContractClass> utgTestContractClassProxyTable = new Dictionary<int, Microsoft.WcfUnit.Library.Test.TestContracts.UTGTestContractClass>();
        
        [TestInitialize()]
        [System.Diagnostics.CodeAnalysis.SuppressMessage(""Microsoft.Reliability"", ""CA2000:Dispose objects before losing scope"", Justification=""proxy should not be disposed"")]
        public void InitializeTest()
        {
            System.Threading.Monitor.Enter(utgTestContractClassProxyTable);
            try
            {
                utgTestContractClassProxyTable.TryGetValue(System.Threading.Thread.CurrentThread.ManagedThreadId, out utgTestContractClassClient);
                if (((utgTestContractClassClient == null) 
                            || (((System.ServiceModel.ICommunicationObject)(utgTestContractClassClient)).State == System.ServiceModel.CommunicationState.Faulted)))
                {
                    // The following line may need to be customised to select the appropriate binding from the configuration file
                    utgTestContractClassClient = new Microsoft.WcfUnit.Library.Test.TestContracts.UTGTestContractClassProxyCommObject();
                    ((System.ServiceModel.ICommunicationObject)(utgTestContractClassClient)).Open();
                    utgTestContractClassProxyTable[System.Threading.Thread.CurrentThread.ManagedThreadId] = utgTestContractClassClient;
                }
            }
            finally
            {
                System.Threading.Monitor.Exit(utgTestContractClassProxyTable);
            }
        }
    }
}
");
        }

        [TestMethod]
        public void UTGChannelFactoryIsUsedWhenThereIsNoProxy()
        {
            UnitTestGenerator utg = CreateUnitTestGenerator();
            utg.GenerateServiceCall(
                null,
                typeof(IUTGTestContract).GetMethod("Operation"),
                new CallParameterInfo[] { },
                this.comment);
            CheckCode(utg,
@"//------------------------------------------------------------------------------
// <auto-generated>
//     This code was generated by a tool.
//     Runtime Version:2.0.50727.1433
//
//     Changes to this file may cause incorrect behavior and will be lost if
//     the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------

namespace TestNamespace
{
    using Microsoft.VisualStudio.TestTools.UnitTesting;
    using System.Collections.Generic;
    
    
    [TestClass()]
    [System.Diagnostics.CodeAnalysis.SuppressMessage(""Microsoft.Design"", ""CA1001:TypesThatOwnDisposableFieldsShouldBeDisposable"", Justification=""proxy should not be disposed"")]
    public partial class TestClass
    {
        
        private TestContext _testContext;
        
        private Microsoft.WcfUnit.Library.Test.TestContracts.IUTGTestContract utgTestContractClient;
        
        public TestContext TestContext
        {
            get
            {
                return this._testContext;
            }
            set
            {
                this._testContext = value;
            }
        }
        
        [TestMethod()]
        public void TestScenario()
        {
            // 11/15/2007 00:00:00
            this.Operation();
        }
        
        private void Operation()
        {
            _testContext.BeginTimer(""TestScenario_Operation"");
            try
            {
                utgTestContractClient.Operation();
            }
            finally
            {
                _testContext.EndTimer(""TestScenario_Operation"");
            }
        }
    }
}
",
@"//------------------------------------------------------------------------------
// <auto-generated>
//     This code was generated by a tool.
//     Runtime Version:2.0.50727.1433
//
//     Changes to this file may cause incorrect behavior and will be lost if
//     the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------

namespace TestNamespace
{
    using Microsoft.VisualStudio.TestTools.UnitTesting;
    using System.Collections.Generic;
    
    
    public partial class TestClass
    {
        
        private static Dictionary<int, Microsoft.WcfUnit.Library.Test.TestContracts.IUTGTestContract> utgTestContractProxyTable = new Dictionary<int, Microsoft.WcfUnit.Library.Test.TestContracts.IUTGTestContract>();
        
        [TestInitialize()]
        [System.Diagnostics.CodeAnalysis.SuppressMessage(""Microsoft.Reliability"", ""CA2000:Dispose objects before losing scope"", Justification=""proxy should not be disposed"")]
        public void InitializeTest()
        {
            System.Threading.Monitor.Enter(utgTestContractProxyTable);
            try
            {
                utgTestContractProxyTable.TryGetValue(System.Threading.Thread.CurrentThread.ManagedThreadId, out utgTestContractClient);
                if (((utgTestContractClient == null) 
                            || (((System.ServiceModel.ICommunicationObject)(utgTestContractClient)).State == System.ServiceModel.CommunicationState.Faulted)))
                {
                    // The following line may need to be customised to select the appropriate binding from the configuration file
                    System.ServiceModel.ChannelFactory<Microsoft.WcfUnit.Library.Test.TestContracts.IUTGTestContract> utgTestContractFactory = new System.ServiceModel.ChannelFactory<Microsoft.WcfUnit.Library.Test.TestContracts.IUTGTestContract>();
                    utgTestContractClient = utgTestContractFactory.CreateChannel();
                    ((System.ServiceModel.ICommunicationObject)(utgTestContractClient)).Open();
                    utgTestContractProxyTable[System.Threading.Thread.CurrentThread.ManagedThreadId] = utgTestContractClient;
                }
            }
            finally
            {
                System.Threading.Monitor.Exit(utgTestContractProxyTable);
            }
        }
    }
}
");
        }

        [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1021:AvoidOutParameters", MessageId = "0#", Justification = "The point of the test is to test out parameters.")]
        [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1021:AvoidOutParameters", MessageId = "1#", Justification = "The point of the test is to test out parameters.")]
        public void OutParameterTestMethod(out int a, out string b)
        {
            a = 1;
            b = null;
        }

        [TestMethod]
        public void UTGOutParametersGeneratedAsOutParametersOnTheProxyAndValueParametersNotInitialised()
        {
            UnitTestGenerator utg = CreateUnitTestGenerator();
            utg.GenerateServiceCall(
                null,
                this.GetType().GetMethod("OutParameterTestMethod"),
                new CallParameterInfo[]
                {
                    new CallParameterInfo("a", typeof(int), FieldDirection.Out, null),
                    new CallParameterInfo("b", typeof(string), FieldDirection.Out, null)
                },
                this.comment);
            CheckCode(utg,
@"//------------------------------------------------------------------------------
// <auto-generated>
//     This code was generated by a tool.
//     Runtime Version:2.0.50727.1433
//
//     Changes to this file may cause incorrect behavior and will be lost if
//     the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------

namespace TestNamespace
{
    using Microsoft.VisualStudio.TestTools.UnitTesting;
    using System.Collections.Generic;
    
    
    [TestClass()]
    [System.Diagnostics.CodeAnalysis.SuppressMessage(""Microsoft.Design"", ""CA1001:TypesThatOwnDisposableFieldsShouldBeDisposable"", Justification=""proxy should not be disposed"")]
    public partial class TestClass
    {
        
        private TestContext _testContext;
        
        private Microsoft.WcfUnit.Library.Test.UnitTestGeneratorTests unitTestGeneratorTestsClient;
        
        public TestContext TestContext
        {
            get
            {
                return this._testContext;
            }
            set
            {
                this._testContext = value;
            }
        }
        
        [TestMethod()]
        public void TestScenario()
        {
            // 11/15/2007 00:00:00
            this.OutParameterTestMethod();
        }
        
        private void OutParameterTestMethod()
        {
            int a;
            string b;
            _testContext.BeginTimer(""TestScenario_OutParameterTestMethod"");
            try
            {
                unitTestGeneratorTestsClient.OutParameterTestMethod(out a, out b);
            }
            finally
            {
                _testContext.EndTimer(""TestScenario_OutParameterTestMethod"");
            }
        }
    }
}
",
@"//------------------------------------------------------------------------------
// <auto-generated>
//     This code was generated by a tool.
//     Runtime Version:2.0.50727.1433
//
//     Changes to this file may cause incorrect behavior and will be lost if
//     the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------

namespace TestNamespace
{
    using Microsoft.VisualStudio.TestTools.UnitTesting;
    using System.Collections.Generic;
    
    
    public partial class TestClass
    {
        
        private static Dictionary<int, Microsoft.WcfUnit.Library.Test.UnitTestGeneratorTests> unitTestGeneratorTestsProxyTable = new Dictionary<int, Microsoft.WcfUnit.Library.Test.UnitTestGeneratorTests>();
        
        [TestInitialize()]
        [System.Diagnostics.CodeAnalysis.SuppressMessage(""Microsoft.Reliability"", ""CA2000:Dispose objects before losing scope"", Justification=""proxy should not be disposed"")]
        public void InitializeTest()
        {
            System.Threading.Monitor.Enter(unitTestGeneratorTestsProxyTable);
            try
            {
                unitTestGeneratorTestsProxyTable.TryGetValue(System.Threading.Thread.CurrentThread.ManagedThreadId, out unitTestGeneratorTestsClient);
                if (((unitTestGeneratorTestsClient == null) 
                            || (((System.ServiceModel.ICommunicationObject)(unitTestGeneratorTestsClient)).State == System.ServiceModel.CommunicationState.Faulted)))
                {
                    // The following line may need to be customised to select the appropriate binding from the configuration file
                    System.ServiceModel.ChannelFactory<Microsoft.WcfUnit.Library.Test.UnitTestGeneratorTests> unitTestGeneratorTestsFactory = new System.ServiceModel.ChannelFactory<Microsoft.WcfUnit.Library.Test.UnitTestGeneratorTests>();
                    unitTestGeneratorTestsClient = unitTestGeneratorTestsFactory.CreateChannel();
                    ((System.ServiceModel.ICommunicationObject)(unitTestGeneratorTestsClient)).Open();
                    unitTestGeneratorTestsProxyTable[System.Threading.Thread.CurrentThread.ManagedThreadId] = unitTestGeneratorTestsClient;
                }
            }
            finally
            {
                System.Threading.Monitor.Exit(unitTestGeneratorTestsProxyTable);
            }
        }
    }
}
");
        }

        [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1045:DoNotPassTypesByReference", MessageId = "0#", Justification = "This is the point of the test.")]
        public void RefParameterTestMethod(ref int a)
        {
        }

        [TestMethod]
        public void UTGRefParameterIsGeneratedAsARefParameterOnTheProxy()
        {
            UnitTestGenerator utg = CreateUnitTestGenerator();
            utg.GenerateServiceCall(
                null,
                this.GetType().GetMethod("RefParameterTestMethod"),
                new CallParameterInfo[] { new CallParameterInfo("a", typeof(int), FieldDirection.Ref, 1) },
                this.comment);
            CheckCode(utg,
@"//------------------------------------------------------------------------------
// <auto-generated>
//     This code was generated by a tool.
//     Runtime Version:2.0.50727.1433
//
//     Changes to this file may cause incorrect behavior and will be lost if
//     the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------

namespace TestNamespace
{
    using Microsoft.VisualStudio.TestTools.UnitTesting;
    using System.Collections.Generic;
    
    
    [TestClass()]
    [System.Diagnostics.CodeAnalysis.SuppressMessage(""Microsoft.Design"", ""CA1001:TypesThatOwnDisposableFieldsShouldBeDisposable"", Justification=""proxy should not be disposed"")]
    public partial class TestClass
    {
        
        private TestContext _testContext;
        
        private Microsoft.WcfUnit.Library.Test.UnitTestGeneratorTests unitTestGeneratorTestsClient;
        
        public TestContext TestContext
        {
            get
            {
                return this._testContext;
            }
            set
            {
                this._testContext = value;
            }
        }
        
        [TestMethod()]
        public void TestScenario()
        {
            // 11/15/2007 00:00:00
            this.RefParameterTestMethod();
        }
        
        private void RefParameterTestMethod()
        {
            int a = 1;
            this.CustomiseRefParameterTestMethod(ref a);
            _testContext.BeginTimer(""TestScenario_RefParameterTestMethod"");
            try
            {
                unitTestGeneratorTestsClient.RefParameterTestMethod(ref a);
            }
            finally
            {
                _testContext.EndTimer(""TestScenario_RefParameterTestMethod"");
            }
        }
    }
}
",
@"//------------------------------------------------------------------------------
// <auto-generated>
//     This code was generated by a tool.
//     Runtime Version:2.0.50727.1433
//
//     Changes to this file may cause incorrect behavior and will be lost if
//     the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------

namespace TestNamespace
{
    using Microsoft.VisualStudio.TestTools.UnitTesting;
    using System.Collections.Generic;
    
    
    public partial class TestClass
    {
        
        private static Dictionary<int, Microsoft.WcfUnit.Library.Test.UnitTestGeneratorTests> unitTestGeneratorTestsProxyTable = new Dictionary<int, Microsoft.WcfUnit.Library.Test.UnitTestGeneratorTests>();
        
        [TestInitialize()]
        [System.Diagnostics.CodeAnalysis.SuppressMessage(""Microsoft.Reliability"", ""CA2000:Dispose objects before losing scope"", Justification=""proxy should not be disposed"")]
        public void InitializeTest()
        {
            System.Threading.Monitor.Enter(unitTestGeneratorTestsProxyTable);
            try
            {
                unitTestGeneratorTestsProxyTable.TryGetValue(System.Threading.Thread.CurrentThread.ManagedThreadId, out unitTestGeneratorTestsClient);
                if (((unitTestGeneratorTestsClient == null) 
                            || (((System.ServiceModel.ICommunicationObject)(unitTestGeneratorTestsClient)).State == System.ServiceModel.CommunicationState.Faulted)))
                {
                    // The following line may need to be customised to select the appropriate binding from the configuration file
                    System.ServiceModel.ChannelFactory<Microsoft.WcfUnit.Library.Test.UnitTestGeneratorTests> unitTestGeneratorTestsFactory = new System.ServiceModel.ChannelFactory<Microsoft.WcfUnit.Library.Test.UnitTestGeneratorTests>();
                    unitTestGeneratorTestsClient = unitTestGeneratorTestsFactory.CreateChannel();
                    ((System.ServiceModel.ICommunicationObject)(unitTestGeneratorTestsClient)).Open();
                    unitTestGeneratorTestsProxyTable[System.Threading.Thread.CurrentThread.ManagedThreadId] = unitTestGeneratorTestsClient;
                }
            }
            finally
            {
                System.Threading.Monitor.Exit(unitTestGeneratorTestsProxyTable);
            }
        }
        
        private void CustomiseRefParameterTestMethod(ref int a)
        {
        }
    }
}
");
        }

        [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1021:AvoidOutParameters", MessageId = "2#", Justification = "This is the point of the test.")]
        [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1045:DoNotPassTypesByReference", MessageId = "0#", Justification = "This is the point of the test.")]
        public void MixedParameterTestMethod(ref int a, int b, out int c)
        {
            c = 99;
        }

        [TestMethod]
        public void UTGMixedDirectionParametersOmitOutParametersOnStubMethod()
        {
            UnitTestGenerator utg = CreateUnitTestGenerator();
            utg.GenerateServiceCall(
                null,
                this.GetType().GetMethod("MixedParameterTestMethod"),
                new CallParameterInfo[]
                {
                    new CallParameterInfo("a", typeof(int), FieldDirection.Ref, 1),
                    new CallParameterInfo("b", typeof(int), FieldDirection.In, 2),
                    new CallParameterInfo("c", typeof(int), FieldDirection.Out, null),
                },
                this.comment);
            CheckCode(utg,
@"//------------------------------------------------------------------------------
// <auto-generated>
//     This code was generated by a tool.
//     Runtime Version:2.0.50727.1433
//
//     Changes to this file may cause incorrect behavior and will be lost if
//     the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------

namespace TestNamespace
{
    using Microsoft.VisualStudio.TestTools.UnitTesting;
    using System.Collections.Generic;
    
    
    [TestClass()]
    [System.Diagnostics.CodeAnalysis.SuppressMessage(""Microsoft.Design"", ""CA1001:TypesThatOwnDisposableFieldsShouldBeDisposable"", Justification=""proxy should not be disposed"")]
    public partial class TestClass
    {
        
        private TestContext _testContext;
        
        private Microsoft.WcfUnit.Library.Test.UnitTestGeneratorTests unitTestGeneratorTestsClient;
        
        public TestContext TestContext
        {
            get
            {
                return this._testContext;
            }
            set
            {
                this._testContext = value;
            }
        }
        
        [TestMethod()]
        public void TestScenario()
        {
            // 11/15/2007 00:00:00
            this.MixedParameterTestMethod();
        }
        
        private void MixedParameterTestMethod()
        {
            int a = 1;
            int b = 2;
            int c;
            this.CustomiseMixedParameterTestMethod(ref a, ref b);
            _testContext.BeginTimer(""TestScenario_MixedParameterTestMethod"");
            try
            {
                unitTestGeneratorTestsClient.MixedParameterTestMethod(ref a, b, out c);
            }
            finally
            {
                _testContext.EndTimer(""TestScenario_MixedParameterTestMethod"");
            }
        }
    }
}
",
@"//------------------------------------------------------------------------------
// <auto-generated>
//     This code was generated by a tool.
//     Runtime Version:2.0.50727.1433
//
//     Changes to this file may cause incorrect behavior and will be lost if
//     the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------

namespace TestNamespace
{
    using Microsoft.VisualStudio.TestTools.UnitTesting;
    using System.Collections.Generic;
    
    
    public partial class TestClass
    {
        
        private static Dictionary<int, Microsoft.WcfUnit.Library.Test.UnitTestGeneratorTests> unitTestGeneratorTestsProxyTable = new Dictionary<int, Microsoft.WcfUnit.Library.Test.UnitTestGeneratorTests>();
        
        [TestInitialize()]
        [System.Diagnostics.CodeAnalysis.SuppressMessage(""Microsoft.Reliability"", ""CA2000:Dispose objects before losing scope"", Justification=""proxy should not be disposed"")]
        public void InitializeTest()
        {
            System.Threading.Monitor.Enter(unitTestGeneratorTestsProxyTable);
            try
            {
                unitTestGeneratorTestsProxyTable.TryGetValue(System.Threading.Thread.CurrentThread.ManagedThreadId, out unitTestGeneratorTestsClient);
                if (((unitTestGeneratorTestsClient == null) 
                            || (((System.ServiceModel.ICommunicationObject)(unitTestGeneratorTestsClient)).State == System.ServiceModel.CommunicationState.Faulted)))
                {
                    // The following line may need to be customised to select the appropriate binding from the configuration file
                    System.ServiceModel.ChannelFactory<Microsoft.WcfUnit.Library.Test.UnitTestGeneratorTests> unitTestGeneratorTestsFactory = new System.ServiceModel.ChannelFactory<Microsoft.WcfUnit.Library.Test.UnitTestGeneratorTests>();
                    unitTestGeneratorTestsClient = unitTestGeneratorTestsFactory.CreateChannel();
                    ((System.ServiceModel.ICommunicationObject)(unitTestGeneratorTestsClient)).Open();
                    unitTestGeneratorTestsProxyTable[System.Threading.Thread.CurrentThread.ManagedThreadId] = unitTestGeneratorTestsClient;
                }
            }
            finally
            {
                System.Threading.Monitor.Exit(unitTestGeneratorTestsProxyTable);
            }
        }
        
        private void CustomiseMixedParameterTestMethod(ref int a, ref int b)
        {
        }
    }
}
");
        }

        private static UnitTestGenerator CreateUnitTestGenerator()
        {
            UnitTestGenerator utg = new UnitTestGenerator(ScenarioName, "TestNamespace", "TestClass", TestMethodMode.ScenarioMethodOnly, OperationTimerMode.IncludeOperationTimers);
            return utg;
        }

        private static void CheckCode(UnitTestGenerator utg, string expectedMainCode, string expectedStubCode)
        {
            string mainFile = Path.GetTempFileName();
            string stubFile = Path.GetTempFileName();
            utg.WriteCode(mainFile, stubFile);
            CompareCode(mainFile, expectedMainCode);
            CompareCode(stubFile, expectedStubCode);
        }

        private static void CompareCode(string actualCodeFileName, string expectedCode)
        {
            string actualCode = File.ReadAllText(actualCodeFileName);
            TestHelper.CompareCode(expectedCode, actualCode);
        }
    }
}
